import numpy as np
import os

def concatenate_npy_files(file1, file2, output_file):
    # Load the two numpy files
    data1 = np.load(file1)
    data2 = np.load(file2)

    # Concatenate the data along the first axis (rows)
    concatenated_data = np.concatenate((data1, data2), axis=0)
    
    concatenated_data = concatenated_data[concatenated_data[:, 0] >= 302]

    # Save the concatenated data to a new file
    np.save(output_file, concatenated_data)
    print(f"Saved concatenated data to {output_file}")
    print(f"Concatenated data shape: {concatenated_data.shape}")

if __name__ == "__main__":
    # Paths to the input .npy files
    file1_path = "1Dflame_60NH3_ULFS_stage1-3.npy"  # Change this to your first file path
    file2_path = "1Dflame_60NH3_ULFS_stage4.npy"  # Change this to your second file path
    
    # Create output file path
    base_name, ext = os.path.splitext(file1_path)
    output_file_path = f"{base_name}_concatenated{ext}"

    # Call the function to concatenate the files and save the result
    concatenate_npy_files(file1_path, file2_path, output_file_path)